<?php   
class ControllerCommonHeader extends Controller {
	protected function index() {
		global $CATEGORIES;
		
		$this->data['title'] = $this->document->getTitle();
		if (!$this->data['title']) {
			$this->data['title'] = C('config_title');
		}
		else {
			$this->data['title'] .= ' - ' . C('config_title');
		}
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$this->data['home'] = C('config_ssl');
		} else {
			$this->data['home'] = C('config_url');
		}
		$this->data['base'] = $this->data['home'];
		
		$this->data['description'] = $this->document->getDescription();
		$this->data['keywords'] = $this->document->getKeywords();
		$this->data['links'] = $this->document->getLinks();	 
		$this->data['styles'] = $this->document->getStyles();
		$this->data['scripts'] = $this->document->getScripts();
		$this->data['lang'] = $this->_['code'];
		$this->data['direction'] = $this->_['direction'];
				
		$this->language->load('common/header');
		
		if (C('config_icon') && file_exists(DIR_IMAGE . C('config_icon'))) {
			$this->data['icon'] = image_url(C('config_icon'));
		} else {
			$this->data['icon'] = '';
		}
		
		$this->data['text_welcome'] = sprintf($this->_['text_welcome'], US('account/login'), US('account/register'));
		$this->data['text_logged'] = sprintf($this->_['text_logged'], US('account/account'), $this->customer->getFirstName(), US('account/logout'));
		$this->data['text_wishlist'] = sprintf($this->_['text_wishlist'], (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
		
		$this->data['logged'] = $this->customer->isLogged();
		
		//Search
		$this->data['search'] = G('search');
		
		// Menu
		$this->data['categories'] = $CATEGORIES;
		$this->children = array(
			'module/language',
			'module/currency',
			'module/cart'
		);
		
    	$this->render('common/header.tpl');
	} 	
}
?>